<?


	function getMonday($weeknr)
	{
		$year = date('Y');
		$offset = date('w', mktime(0,0,0,1,1,$year));
		$offset = ($offset < 5) ? 1-$offset : 8-$offset;
		$monday = mktime(0,0,0,1,1+$offset,$year);
		return   strtotime('+' . ($weeknr - 1) . ' weeks', $monday);
	}
	
	function getDateforWeek($day, $weeknr)
	{
		$year = date('Y');
		$offset = date('w', mktime(0,0,0,1,1,$year));
		$offset = ($offset < 5) ? 1-$offset : 8-$offset;
		$day = mktime(0,0,0,1,$day+$offset,$year);
		return   strtotime('+' . ($weeknr - 1) . ' weeks', $day);
	}
	
	function getFriday($weeknr)
	{
		$year = date('Y');
		$offset = date('w', mktime(0,0,0,1,1,$year));
		$offset = ($offset < 5) ? 1-$offset : 8-$offset;
		$friday = mktime(0,0,0,1,5+$offset,$year);
		return   strtotime('+' . ($weeknr - 1) . ' weeks', $friday);
	}
	
	function getFirstAndLastDayOfWeek($week)
	{	
		$monDate = date ('d.m.', getMonday($week));
		$friDate = date ('d.m.', getFriday($week));
		return " ". $monDate. " - " . $friDate;
	}
	
	
?>